package insat.ia.helpers;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class FileHelpers {

    private String filename;
    private ArrayList<String> data;

    public FileHelpers(String f) {

        filename = f;
        data = new ArrayList<String>();
    }

    public void createData() {

        File f = new File(filename);
        FileReader fr = null;
        try {
            fr = new FileReader(f);
        } catch (FileNotFoundException e) {
            System.out.println("erreur de lecture !");
            e.printStackTrace();
        }
        BufferedReader br = new BufferedReader(fr);

        String s = null;

        try {
            while ((s = br.readLine()) != null) {
                data.add(s);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        try {
            br.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public String getFilename() {
        return filename;
    }

    public void setFilename(String filename) {
        this.filename = filename;
    }

    public ArrayList<String> getData() {
        return data;
    }

    public void setData(ArrayList<String> data) {
        this.data = data;
    }

}
